package com.kinghood.authoritycenter.controller.sys;

import com.kinghood.infrastructure.api.authority.AddSysLogReqDTO;
import com.kinghood.authoritycenter.common.model.dto.organization.SysLogQueryReqDTO;
import com.kinghood.authoritycenter.common.model.vo.sys.QueryLogPageVO;
import com.kinghood.authoritycenter.service.ISysLogService;
import com.kinghood.infrastructure.model.KingHoodResponseVO;
import com.kinghood.sharding.model.PageResponseVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author KingHood
 * @since 2024-01-03
 */
@RequiredArgsConstructor
@Slf4j
@RestController
@RequestMapping("/sysLog")
public class SysLogController {

    private final ISysLogService sysLogService;

    /**
     * 日志分页
     *
     * @param in 筛选条件
     * @return 日志
     * @author zfj
     * @date 2024/01/03
     */
    @PostMapping("/queryLogPage")
    public KingHoodResponseVO<PageResponseVO<QueryLogPageVO>> queryLogPage(@RequestBody SysLogQueryReqDTO in) {

        return KingHoodResponseVO.success(sysLogService.queryLogPage(in));
    }

    /**
     * 新增系统日志
     *
     * @param in 日志
     * @return 日志id
     * @author zfj
     * @date 2024/01/03
     */
    @PostMapping("/addLog")
    public KingHoodResponseVO<Long> addLog(@Valid @RequestBody AddSysLogReqDTO in) {

        return KingHoodResponseVO.success(sysLogService.addLog(in));
    }

}
